﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Net;

namespace ERF {
    /// <summary>
    /// Class for handling all players in game.
    /// </summary>
    abstract public class PlayerHandler {
        protected ERFGame game;
        protected ERF.NetworkHandler networkHandler;

        public PlayerHandler(ERFGame game) {
            this.game = game;
            this.networkHandler = game.NetworkHandler;
            this.HookNetwork();
        }

        /// <summary>
        /// Binds gamerjoined and gamerleft to functions.
        /// </summary>
        private void HookNetwork() {
            this.networkHandler.GamerJoined += new EventHandler<GamerJoinedEventArgs>(this.network_GamerJoined);
            this.networkHandler.GamerLeft += new EventHandler<GamerLeftEventArgs>(this.network_GamerLeft);
        }

        /// <summary>
        /// Called when gamer joins game.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected abstract void network_GamerJoined(object sender, GamerJoinedEventArgs e);
        /// <summary>
        /// Called when gamer leaves game.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected abstract void network_GamerLeft(object sender, GamerLeftEventArgs e);
    }
}
